package com.citytransport.prokopjuk.dao;

import java.util.ArrayList;
import java.util.Random;

import org.h2.constant.SysProperties;

import com.citytransport.prokopjuk.builder_strategy.Director;
import com.citytransport.prokopjuk.builder_strategy.SimpleRouteBuilder;
import com.citytransport.prokopjuk.route.Route;
import com.citytransport.prokopjuk.route.Station;
import com.citytransport.prokopjuk.vehicleDTO.Bus;
import com.citytransport.prokopjuk.vehicleDTO.InternalCombustionEngineType;
import com.citytransport.prokopjuk.vehicleDTO.Tram;
import com.citytransport.prokopjuk.vehicleDTO.Trolleybus;

public class TestCRUD {
    public static void main(String[] args) {
//	DAOStation daoStation = new DAOStation();
//	DAORoute daoRoute= new DAORoute();
//	int routeID = 4;
//	Route tmp = daoRoute.read(routeID);
//	int price = tmp.getPrice();
//	int intervalMinute = tmp.getIntervalMinute();
//	ArrayList<Station> stations = new ArrayList<Station>(daoStation.readAtRoute(routeID));
//	SimpleRouteBuilder builder = new SimpleRouteBuilder(daoRoute.readVehicle(routeID), 
//		stations, price, intervalMinute, routeID);
//	Director director = new Director();
//	director.setRouteBuilder(builder);
//	director.createRoute();
//	System.out.println(director.getRoute());
	
	DAOStation d = new DAOStation();
	d.delete(new Station("fdfd", true, false));
    }

    private static void DAOTramTest() {
	DAOTram dao = new DAOTram();
	Tram tram0 = new Tram(30, "adadasd", "model", true, 3);
	Tram tram1 = new Tram(20, "222222", "model2", true, 2);
	dao.creat(tram0);
	dao.creat(tram1);

	dao.update(tram0, 1, "update", "update", 0, true, 2);
	System.out.println(dao.readAll());
	dao.deleteAll();
    }

    private static void DAOBusTest() {
	DAOBus dao = new DAOBus();
	Bus bus0 = new Bus(30, "AA3485GF", "bogdan", true, 3, 6,
		InternalCombustionEngineType.Gass);
	Bus bus1 = new Bus(2, "AA3485GF", "bogdan", true, 3, 6,
		InternalCombustionEngineType.Gass);
	Bus bus2 = new Bus(3, "AA3485GF", "bogdan", true, 3, 6,
		InternalCombustionEngineType.Gass);
	dao.create(bus0);
	dao.create(bus1);
	dao.create(bus2);
	System.out.println(dao.readAll());
	dao.deleteAllBus();
    }

    private static void testDAOVehicle() {
	DAOVehicle dao = new DAOVehicle();
	Tram tram = new Tram(30, "AA4354CB", "model", true, 2);
	// TODO fix bag.routeID must be denied
	tram.setRouteID(323);
	dao.create(tram);
	System.out.println(dao.read(1));
	dao.delete(tram);
    }

    private static void DAORouteTest() {
	DAORoute dao = new DAORoute();
	Route route = new Route();
	route.setRouteID(192);
	route.setIntervalMinute(7);
	route.setPrice(200);

	System.out.println("test3");
	dao.create(route);
	dao.update(route, 7, 4, 3);
	System.out.println(dao.read(7));
	dao.deleteAllRoutes();
    }

    private static void testStationDAO() {
	DAOStation dao = new DAOStation();
	// System.out.println("Station station1 = new Station(1,\"Name \", true, true);");
	// System.out.println("Station station2 = new Station(2,\"Troja\", false, true);");
	// System.out.println("Station station3 = new Station(3, \"Shototam\", true, true);");

	Station station1 = new Station(1, "Name ", true, true);
	Station station2 = new Station(2, "Troja", false, true);
	Station station3 = new Station(3, "Shototam", true, true);

	// System.out.println("**********************************************");
	// System.out.println("dao.create(station1)");
	// System.out.println("dao.create(station2)");
	// System.out.println("dao.create(station2)");
	// System.out.println("**********************************************");
	dao.create(station1);
	dao.create(station2);
	dao.create(station3);

	System.out.println("dao.read()");

	System.out.println(dao.readAllStations());

	System.out.println("dao.delete(station1)");
	dao.delete(station1);
	System.out.println(dao.readAllStations());
	System.out.println("**********************************************");

	dao.update(station2, "Renamedstation2", true, false);
	System.out.println(dao.readAllStations());
	System.out.println("**********************************************");
	System.out.println("dao.deleteAll()");
	dao.deleteAll();
    }

}
